str object has no attribute keys when attempting to write a dictionary to csv in python 3